package com.hqq.exercise.math;

import java.util.Scanner;

/**
 * SqrtSum 平方和问题
 * 题目描述:
 * 在区间[N,M]中 满足1<=A<N 1<=B<=M中 (sqrt(A)+sqrt(B))^2是整数的个数
 * ps:内存空间优化
 * (sqrt(a) + sqrt(b)) (sqrt(a) + sqrt(b))
 * = sqrt(a) sqrt(a) + 2 sqrt(a) sqrt(b) + sqrt(b) sqrt(b)
 * = sqrt(a a) + 2 sqrt(a b) + sqrt(bb)
 * = a + 2 sqrt(a * b) + b
 * Created by heqianqian on 2017/9/11.
 */
public class SqrtSum {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        System.out.println(solve(N, M));
    }

    private static int solve(int N, int M) {
        int res = 0;
        for (int a = 1; a <= N; a++) {
            int s = 1;
            //O(sqrt(N))
            //找到最大的s 让a是s*s的倍数
            for (int x = 2; x <= a / x; x++) {
                if (a % (x * x) == 0) {
                    s = x * x;
                }
            }
            int r = a / s;
            for (int y = 1; y * y * r <= M; y++) {
                res++;
            }
        }
        return res;
    }
}
